<?php
/**
 * Created by PhpStorm.
 * User: jiaer
 * Date: 2019/8/15
 * Time: 15:10
 */

namespace app\admin\controller;

use app\self\controller\Extend;
use think\Db;

class Position extends Extend
{
    public $database = 's_position';

    public $type = '职位管理';


    public function searchWhere()
    {

        $search = [
            ['field'=>'name','name'=>'名称'],

        ];
        $this->assign('search',$search);
        $this->assign('searchJs',json_encode($search));

    }

    public function mapSelf()
    {
        return ['is_delete'=>0];
    }

    public function getField()
    {
        $id = input('id/d',0);
        $result = Db::name($this->database)
            ->where(['id'=>$id])
            ->find();
        $edit = [

            ['field'=>'name','name'=>'名称','value'=>$result['name']],
            ['field'=>'status','name'=>'状态','value'=>empty($result['status'])? 0 : $result['status'],'type'=>'select','option'=>['正常','禁用']],
            ['field'=>'remark','name'=>'备注','value'=>$result['remark']],
        ];
        return $edit;
    }

    public function postVerification($data,$id)
    {
        if(empty($data['name'])) return fieldEmpty('名称'); //字段不能为空
    }


}
